/*

MArray

*/

#include "marray.h"

#ifndef MARRAY_C
#define MARRAY_C

#include <stdlib.h>
#include <string.h>

MArray* createMArray() {
	MArray* ha = (MArray*)malloc(sizeof(MArray));
	ha->size = 0;
	ha->msize = 0;
	ha->d = NULL;
	return ha;
};

void addMArrayEl(void* src, unsigned int size, MArray* ha) {
	unsigned int newsize = ha->size + size;
	if(newsize > ha->msize) {
		ha->msize = newsize + MARRAY_MEM_BLOCK;
		ha->d = realloc(ha->d, ha->msize);
	};

	memcpy(ha->d + ha->size, src, size);
	ha->size = newsize;
};

void freeMArray(MArray* ha) {
	free(ha->d);
	free(ha);
};


#endif
